﻿using LuShanTea.Admin.Web.App_Start;
using LuShanTea.Admin.Web.Models;
using LuShanTea.IService;
using LuShanTea.Web.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace LuShanTea.Admin.Web.Controllers
{
    
    public class AddressController : Controller
    {
        public IAddressService AddressService { get; set; }

        // GET: Address
        [CheckPermission("Address")]
        public ActionResult List(int index = 1)
        {
            AddressListModel model = new AddressListModel();
            model.AddressDTO = AddressService.GetPageAddress(index, 10);
            LuShanTealPager page = new LuShanTealPager();
            page.PageIndex = index;
            page.TotalCount = AddressService.GetTotalCount();

            page.UrlPattern = "/Address/List?index={pn}";
            page.MaxPagerCount = 10;
            page.CurrentLinkClassName = "layui-laypage-em";
            model.PageStr = page.GetPager();
            model.TotalCount = page.TotalCount;
            return View(model);
        }

        [HttpPost]
        [CheckPermission("Address")]
        public ActionResult Delete(long id)
        {
            AddressService.MarkDelete(id);
            return Json(new AjaxResult { Status="ok" });
        }
      

    }
}